<?php
/**
 * Created by PhpStorm.
 * User=> 杨海
 * Date=> 2021/3/24
 * Time=> 16=>22
 */

namespace app\index\controller;


use think\facade\Cookie;
use think\facade\Session;

class menu
{
    /**
     * [
    {
    "id"=> "2",
    "title"=> "用户",
    "icon"=> "layui-icon layui-icon-component",
    "type"=> 0,
    "href"=> "",
    "children"=> [
    {
    "id"=> 201,
    "title"=> "用户管理",
    "icon"=> "layui-icon layui-icon-console",
    "type"=> 1,
    "openType"=> "_iframe",
    "href"=> "http=>//www.yd2021.com/index/User/index"
    }
    ]
    },
    {
    "id"=> 1,
    "title"=> "小程序后台",
    "type"=> 0,
    "icon"=> "layui-icon layui-icon-console",
    "href"=> "",
    "children"=> [
    {
    "id"=> 8,
    "title"=> "新闻页面",
    "icon"=> "layui-icon layui-icon-console",
    "type"=> 1,
    "openType"=> "_iframe",
    "href"=> "http=>//www.yd2021.com/index/Article/Article"
    },
    {
    "id"=> 9,
    "title"=> "新闻轮播",
    "icon"=> "layui-icon layui-icon-console",
    "type"=> 1,
    "openType"=> "_iframe",
    "href"=> "http=>//www.yd2021.com/index/Banner/index"
    }
    ]
    }
    ]
     */
    public function data()
    {
        $user =  Session::get("userInfo.name");
        if (in_array($user,["admin","root"])) {
            $data[] = [
                "id"=> "2",
                "title"=> "用户",
                "icon"=> "layui-icon layui-icon-user",
                "type"=> 0,
                "href"=> "",
                "children"=> [
                    [
                        "id"=> 201,
                        "title"=> "用户管理",
                        "icon"=> "layui-icon layui-icon-console",
                        "type"=> 1,
                        "openType"=> "_iframe",
                        "href"=> url("/index/User/index")
                    ]
                ]
            ];
        }

        $data[]  = [
            "id"=> 1,
            "title"=> "小程序后台",
            "type"=> 0,
            "icon"=> "layui-icon layui-icon-release",
            "href"=> "",
            "children"=> [
                [
                    "id"=> 8,
                    "title"=> "新闻页面",
                    "icon"=> "layui-icon layui-icon-console",
                    "type"=> 1,
                    "openType"=> "_iframe",
                    "href"=> url("/index/Article/Article")
                ],
                [
                    "id"=> 9,
                    "title"=> "新闻轮播",
                    "icon"=> "layui-icon layui-icon-console",
                    "type"=> 1,
                    "openType"=> "_iframe",
                    "href"=> url("/index/Banner/index")
                ]
            ]
        ];


        return json($data);

    }
}